import {reqPost,reqGet} from './http'

//首页的分类
let getIndexCates=()=>{
    return reqGet('/api/getcate')
}
//轮播图
let getIndexBanners=()=>{
    return reqGet('/api/getbanner')
}
//主页的商品
let getIndexGoods=()=>{
    return reqGet('/api/gethortgoods')
}
//分类页的分类
let getCate_cates=()=>{
    return reqGet('/api/getcates')
}
//列表页
let getCateList=({cateid})=>{
    return reqGet('/api/getgoodlist',{cateid})
}
//登录
let doLogin=(user)=>{
    return reqPost('/api/login',user)
}
//注册
let doRegister=(user)=>{
    return reqPost('api/register',user)
}
//搜索页
let doSearch=(keywords)=>{
    return reqGet('api/search',{keywords})
}
//详情页
let getGoodsInfo=(id)=>{
    return reqGet('api/getgoodsinfo',{id})
}
//购物车列表
let getShopCarList=(uid)=>{
    return reqGet('/api/cartlist',{uid})
}
//购物车添加
let shopCarAdd=(data)=>{
    return reqPost('/api/cartadd',data)
}
//购物车修改
let shopCarEdit=(data)=>{
    return reqPost('/api/cartedit',data)
}
//购物车删除
let shopCaDel=(id)=>{
    return reqPost('/api/cartdelete',{id})
}
//地址列表
let addressList=(uid)=>{
    return reqGet('/api/addresslist',{uid})
}
//地址添加
let addressAdd=(data)=>{
    return reqPost('/api/addressadd',data)
}
//地址修改
let addressEdit=(data)=>{
    return reqPost('/api/addressedit',data)
}
//地址删除
let addressDel=(id)=>{
    return reqPost('/api/addressremove',{id})
}
//订单生成
let orderAdd=(data)=>{
    return reqPost('/api/orderadd',data)
}
export {
    getIndexCates,
    getIndexBanners,
    getIndexGoods,
    getCate_cates,
    getCateList,
    doLogin,
    doRegister,
    doSearch,
    getGoodsInfo,
    getShopCarList,
    shopCarAdd,
    shopCarEdit,
    shopCaDel,
    addressList,
    addressAdd,
    addressEdit,
    addressDel,
    orderAdd
}